home *** CD-ROM | disk | FTP | other *** search
- unit Utilities;
-
- {$R-}
- { No range checking }
-
- interface
-
- uses ROM85, SANE;
-
- const
- {Useful MacConstants}
- BtnControlOff = 0;
- BtnControlOn = 1;
- DefaultItem = 1;
- Margin5 = 5;
- Margin16 = 16;
- ScrollBarSize = Margin16;
- WindowTitle = 18;
- MenuBarSize = 20;
- EighthSecond = 8;
- QuarterSecond = 15;
- HalfSecond = 30;
- OneSecond = 60;
- NewRomsID = 117;
- DeadControl = 255;
- TESelStart = 0;
- TESelEnd = 32767;
- TooMuch = 16777216;
-
- {Useful Mac Key code constants}
- ETX = $03; {Enter Key}
- EnterKey = ETX;
- BS = $08; {BackSpace Key}
- CR = $0D; {Return Key}
- ReturnKey = CR;
- HT = $09; {TAB Key}
- TabKey = HT;
- ESC = $1B; {Escape Key}
- FS = $1C; {Left arrow key}
- LeftArrow = FS;
- GS = $1D; {Right arrow key}
- RightArrow = GS;
- RS = $1E; {Up arrow key}
- UpArrow = RS;
- US = $1F; {Down arrow key}
- DownArrow = US;
- EndofLine = $7F; {End of Line Delimeter}
- NoBrkSpace = $CA; {None Breaking space for Mono Spacing}
-
- {Utility Dialog Constants}
- YesNoCancelID = 1966;
- YesButton = 1;
- CancelButton = 2;
- NoButton = 3;
- StaticText = 4;
-
- type
- GenericResponse = (nullResponse, YesResponse, CancelResponse, NoResponse);
-
- var
- theDialogFilter: ProcPtr;
- ScreenSize: Rect;
-
- procedure StandardInit;
- function GetEven(theNum: LONGINT): LONGINT;
- function EnumValue(theValue: INTEGER): SignedByte;
- function GetRectSize(theRect: Rect): Point;
- function NewRoms: BOOLEAN;
- function HFSRunning: BOOLEAN;
- function OptKeyDown(theModifiers: INTEGER): BOOLEAN;
- function CapsLockDown(theModifiers: INTEGER): BOOLEAN;
- function ShiftKeyDown(theModifiers: INTEGER): BOOLEAN;
- function CmdKeyDown(theModifiers: INTEGER): BOOLEAN;
- function WindowActivate(theModifiers: INTEGER): BOOLEAN;
- procedure CenterInRect(var theRect: Rect;
- theCenterRect: Rect;
- vOffSet, hOffSet: INTEGER);
- procedure CenterInScreen(var theRect: Rect;
- vOffSet, hOffSet: INTEGER);
- function GetWindowKind(theWindow: WindowPtr): INTEGER;
- function FrontSysWindow: BOOLEAN;
- function CenterNewWindow(theWindowID: INTEGER;
- wStorage: Ptr;
- behind: WindowPtr;
- vOffSet, hOffSet: INTEGER): WindowPtr;
- procedure ToggleButton(theControl: ControlHandle);
- procedure SetButtonGroup(theDialog: DialogPtr;
- theFirstButton, theLastButton, theButton: INTEGER);
- function GetSetButton(theDialog: DialogPtr;
- theFirstButton, theLastButton: INTEGER): INTEGER;
- procedure SelEditText(theDialog: DialogPtr;
- theItem: INTEGER);
- procedure SetEditText(theDialog: DialogPtr;
- theItem: INTEGER;
- var theText: str255);
- function GetEditText(theDialog: DialogPtr;
- theItem: INTEGER): str255;
- procedure SetEditReal(theDialog: DialogPtr;
- theItem: INTEGER;
- theNumber: Extended;
- theForm: DecForm);
- function GetEditReal(theDialog: DialogPtr;
- theItem: INTEGER;
- var theNumber: Extended): BOOLEAN;
- function DoSFGet(theFileCount: INTEGER;
- theTypeList: SFTypeList;
- vOffSet, hOffSet: INTEGER): SFReply;
- function DoSFPut(var theSavePrompt, OrigFileName: str255;
- vOffSet, hOffSet: INTEGER): SFReply;
- function CenterNewDialog(theDialogID: INTEGER;
- dStorage: Ptr;
- behind: WindowPtr;
- vOffSet, hOffSet: INTEGER): DialogPtr;
- procedure OutLineButton(thePort: GrafPtr;
- theRect: Rect);
- procedure DialogDefault(theDialog: DialogPtr);
- procedure SetupDialog(theDialog: DialogPtr;
- ButtonKeys, CheckBoxKeys, RadioKeys: BOOLEAN);
- procedure DisposSetUp(theDialog: DialogPtr);
- function GetDLOGRefCon(theDialog: DialogPtr): LONGINT;
- function YesNoCancelDLOG(var parm0, parm1, parm2,
- parm3: str255): GenericResponse;
- function YesNoDLOG(var parm0, parm1, parm2, parm3: str255): GenericResponse;
- function DeleteFile: BOOLEAN;
-
- implementation
-
- const
- ButtonItem = 4;
- CheckBox = 5;
- RadioButton = 6;
-
- type
- str1 = STRING[1];
- KeyReplaceRec = record
- Key: str1;
- Item: INTEGER;
- end; {record KeyReplace}
- KeyReplacePtr = ^KeyReplaceRec;
- KeyReplaceHDL = ^KeyReplacePtr;
-
- KeyListArray = array [1..1] of KeyReplaceRec;
- KeyListPtr = ^KeyListArray;
- KeyListHDL = ^KeyListPtr;
-
- KeyListRec = record
- ListHDL: KeyListHDL;
- ListCount, LastItem: INTEGER;
- OldRefCon, LastTime: LONGINT;
- end; {record KeyListRec}
- KeyListRecPtr = ^KeyListRec;
- KeyListRecHDL = ^KeyListRecPtr;
-
- DLOGHeaderRec = record
- ItemCount: INTEGER;
- end; {DLOGHeader}
- DLOGHeaderPtr = ^DLOGHeaderRec;
- DLOGHeaderHDL = ^DLOGHeaderPtr;
-
- procedure ResumeProgram;
- begin
- ExitToShell;
- end; {ResumeProgram}
-
- procedure StandardInit;
- var
- Screen_Width, Screen_Height: INTEGER;
- begin
- InitGraf(@thePort);
- InitFonts;
- InitWindows;
- InitMenus;
- TEInit;
- InitDialogs(@ResumeProgram);
- InitCursor;
- InitAllPacks;
-
- Screen_Width:=screenbits.bounds.right;
- Screen_Height:=screenbits.bounds.bottom;
- SetRect(ScreenSize, 0, MenuBarSize, Screen_Width, Screen_Height);
- InsetRect(ScreenSize, Margin5, Margin5);
-
- theDialogFilter:=nil;
- end; {Initalize}
-
- function GetEven;
- begin
- if ODD(theNum) then
- theNum:=SUCC(theNum)
- else
- GetEven:=theNum;
- end; {Get_Even}
-
- function EnumValue;
- begin
- EnumValue:=theValue;
- end; {EnumValue}
-
- function NewRoms;
- var
- RomVersion, Machine: INTEGER;
- begin
- Environs(RomVersion, Machine);
- NewRoms:=RomVersion>=NewRomsID;
- end; {NewRoms}
-
- function HFSRunning;
- const
- FSFCBLen = $3F6;
- var
- HFS: ^INTEGER;
- begin
- HFS:=POINTER(FSFCBLen);
- HFSRunning:=(HFS^>0);
- end; {HFSRunning}
-
- function OptKeyDown;
- begin
- OptKeyDown:=BitAnd(theModifiers, optionKey)>0;
- end; {OptKeyDown}
-
- function CapsLockDown;
- begin
- CapsLockDown:=BitAnd(theModifiers, alphaLock)>0;
- end; {CapsLockDown}
-
- function ShiftKeyDown;
- begin
- ShiftKeyDown:=BitAnd(theModifiers, shiftKey)>0;
- end; {ShiftKeyDown}
-
- function CmdKeyDown;
- begin
- CmdKeyDown:=BitAnd(theModifiers, cmdKey)>0;
- end; {CmdKeyDown}
-
- function WindowActivate;
- begin
- WindowActivate:=BitAnd(theModifiers, activeFlag)>0;
- end; {WindowActivate}
-
- function GetRectSize;
- var
- TempPoint: Point;
- begin
- TempPoint.v:=theRect.bottom-theRect.top;
- TempPoint.h:=theRect.right-theRect.left;
- GetRectSize:=TempPoint;
- end; {GetRectSize}
-
- procedure CenterInRect;
- var
- RectSize: Point;
- begin
- {Calculate the Width and Height of the Display Rectangle}
- RectSize:=GetRectSize(theRect);
-
- {Center the Display Rect in the CenterRect}
- theRect.top:=ROUND(theCenterRect.bottom/2)-ROUND(RectSize.v/2);
- theRect.left:=ROUND(theCenterRect.right/2)-ROUND(RectSize.h/2);
-
- {Offset the Display Rect by the Requested Amount}
- theRect.top:=theRect.top+vOffSet;
- theRect.left:=theRect.left+hOffSet;
-
- {Move the Bottom Right to the new Position for Centering}
- theRect.bottom:=theRect.top+RectSize.v;
- theRect.right:=theRect.left+RectSize.h;
- end; {CenterInRect}
-
- procedure CenterInScreen;
- var
- TempRect: Rect;
- begin
- TempRect:=screenbits.bounds;
- TempRect.top:=TempRect.top+SUCC(MenuBarSize);
- CenterInRect(theRect, TempRect, vOffSet, hOffSet);
- end; {Center_Rect}
-
- function GetWindowKind;
- var
- TempWindow: WindowPeek;
- begin
- TempWindow:=WindowPeek(theWindow);
- GetWindowKind:=TempWindow^.windowKind;
- end; {Get_WindowKind}
-
- function FrontSysWindow;
- begin
- if FrontWindow<>nil then
- FrontSysWindow:=(GetWindowKind(FrontWindow)<0)
- else
- FrontSysWindow:=FALSE;
- end; {Front_SysWindow}
-
- function CenterNewWindow;
- var
- Window: WindowPtr;
- WindowRect: Rect;
- begin
- Window:=GetNewWindow(theWindowID, wStorage, behind);
- WindowRect:=Window^.portRect;
- CenterInScreen(WindowRect, vOffSet, hOffSet);
- MoveWindow(Window, WindowRect.left, WindowRect.top, TRUE);
- CenterNewWindow:=Window;
- end; {CenterNewWindow}
-
- function DoSFGet;
- var
- TempDialog: DialogPtr;
- TempReply: SFReply;
- TempRect: Rect;
- Corner: Point;
- begin
- TempDialog:=GetNewDialog(getDlgID, nil, nil);
- TempRect:=TempDialog^.portRect;
- CenterInScreen(TempRect, vOffSet, hOffSet);
- DisposDialog(TempDialog);
- Corner.v:=TempRect.top;
- Corner.h:=TempRect.left;
-
- SFGetFile(Corner, '', nil, theFileCount, theTypeList, nil, TempReply);
- DoSFGet:=TempReply;
- end; {Do_SFGet}
-
- function DoSFPut;
- var
- TempDialog: DialogPtr;
- TempReply: SFReply;
- TempRect: Rect;
- Corner: Point;
- begin
- TempDialog:=GetNewDialog(putDlgID, nil, nil);
- TempRect:=TempDialog^.portRect;
- CenterInScreen(TempRect, vOffSet, hOffSet);
- DisposDialog(TempDialog);
- Corner.h:=TempRect.left;
- Corner.v:=TempRect.top;
-
- SFPutFile(Corner, theSavePrompt, OrigFileName, nil, TempReply);
- DoSFPut:=TempReply;
- end; {Do_SFPut}
-
- procedure ToggleButton;
- begin
- SetCtlValue(theControl, SUCC(-(GetCtlValue(theControl))));
- end; {ToggleButton}
-
- procedure SetButtonGroup;
- var
- ItemRect: Rect;
- ItemHDL: Handle;
- ControlHDL: ControlHandle;
- ItemType, Loop: INTEGER;
- begin
- for Loop:=theFirstButton to theLastButton do
- begin
- GetDItem(theDialog, Loop, ItemType, ItemHDL, ItemRect);
- ControlHDL:=ControlHandle(ItemHDL);
- if Loop<>theButton then
- begin
- if GetCtlValue(ControlHDL)>0 then ToggleButton(ControlHDL);
- end {if Loop <> theButton}
- else if GetCtlValue(ControlHDL)=0 then ToggleButton(ControlHDL);
- end; {for Loop := theFirstButton to theLastButton}
- end; {SetButtonGroup}
-
- function GetSetButton;
- var
- ItemRect: Rect;
- ItemHDL: Handle;
- ControlHDL: ControlHandle;
- ItemType, Loop: INTEGER;
- begin
- GetSetButton:=0;
- for Loop:=theFirstButton to theLastButton do
- begin
- GetDItem(theDialog, Loop, ItemType, ItemHDL, ItemRect);
- ControlHDL:=ControlHandle(ItemHDL);
- if GetCtlValue(ControlHDL)>0 then GetSetButton:=Loop;
- end; {for Loop := theFirstButton to theLastButton}
- end; {GetSetButton}
-
- procedure SelEditText;
- var
- ItemRect: Rect;
- ItemHDL: Handle;
- ItemType: INTEGER;
- begin
- GetDItem(theDialog, theItem, ItemType, ItemHDL, ItemRect);
- SelIText(theDialog, theItem, TESelStart, TESelEnd)
- end; {SetEditText}
-
- procedure SetEditText;
- var
- ItemRect: Rect;
- ItemHDL: Handle;
- ItemType: INTEGER;
- begin
- GetDItem(theDialog, theItem, ItemType, ItemHDL, ItemRect);
- SetIText(ItemHDL, theText);
- end; {SetEditText}
-
- function GetEditText;
- var
- ItemStr: str255;
- ItemRect: Rect;
- ItemHDL: Handle;
- ItemType: INTEGER;
- begin
- GetDItem(theDialog, theItem, ItemType, ItemHDL, ItemRect);
- GetItext(ItemHDL, ItemStr);
- GetEditText:=ItemStr;
- end; {GetEditText}
-
- procedure SetEditReal;
- var
- NumberStr: DecStr;
- begin
- Num2Str(theForm, theNumber, NumberStr);
- SetEditText(theDialog, theItem, NumberStr);
- end; {SetEditReal}
-
- function GetEditReal;
- var
- NumberStr: str255;
- TempReal: Extended;
- LegalDigits: set of CHAR;
- Loop: INTEGER;
- GoodNumber: BOOLEAN;
- begin
- LegalDigits:=(['0'..'9', '.', '-']);
- NumberStr:=GetEditText(theDialog, theItem);
-
- TempReal:=Str2Num(NumberStr);
- GoodNumber:=TRUE;
- for Loop:=1 to Length(NumberStr) do
- GoodNumber:=GoodNumber and (NumberStr[Loop] in LegalDigits);
- if GoodNumber then theNumber:=TempReal;
-
- GetEditReal:=GoodNumber;
- end; {GetEditReal}
-
- function KeyMatch(theListRecHDL: KeyListRecHDL;
- theCharacter: str1): INTEGER;
- var
- TempStr1, TempStr2: str255;
- Loop: INTEGER;
- begin
- KeyMatch:=0;
- TempStr1:=theCharacter;
- for Loop:=1 to theListRecHDL^^.ListCount do
- begin
- TempStr2:=theListRecHDL^^.ListHDL^^[Loop].Key;
- if EqualString(TempStr1, TempStr2, FALSE, FALSE) then
- KeyMatch:=Loop;
- end; {for Loop := 1 to theListRecHDL^^.ListCount}
- end; {KeyMatch}
-
- procedure AddKey(theListRecHDL: KeyListRecHDL;
- theControl: ControlHandle;
- theItemNumber: INTEGER);
- var
- TempKey: KeyReplaceRec;
- ControlTitle: str255;
- ByteCount: LONGINT;
- begin
- GetCTitle(theControl, ControlTitle);
-
- if KeyMatch(theListRecHDL, Copy(ControlTitle, 1, 1))=0 then
- begin
- TempKey.Key:=Copy(ControlTitle, 1, 1);
- TempKey.Item:=theItemNumber;
-
- theListRecHDL^^.ListCount:=SUCC(theListRecHDL^^.ListCount);
- ByteCount:=GetEven(SIZEOF(KeyReplaceRec))*theListRecHDL^^.ListCount;
-
- if theListRecHDL^^.ListHDL=nil then
- theListRecHDL^^.ListHDL:=KeyListHDL(NewHandle(ByteCount))
- else
- SetHandleSize(Handle(theListRecHDL^^.ListHDL), ByteCount);
-
- theListRecHDL^^.ListHDL^^[theListRecHDL^^.ListCount]:=TempKey;
- end; {if KeyMatch(theListRecHDL, ControlTitle[1]) = 0}
- end; {AddKey}
-
- function DoDialogMouse(theListHDL: KeyListRecHDL;
- theDialog: DialogPtr;
- theEvent: EventRecord;
- var theItem: INTEGER): BOOLEAN;
- var
- SavePort: GrafPtr;
- ControlHDL: ControlHandle;
- ItemHDL: Handle;
- ItemRect: Rect;
- LocalPoint: Point;
- ItemType, ControlPart: INTEGER;
- begin
- DoDialogMouse:=FALSE;
- GetPort(SavePort);
- SetPort(theDialog);
-
- LocalPoint:=theEvent.where;
- GlobaltoLocal(LocalPoint);
- ControlPart:=FindControl(LocalPoint, theDialog, ControlHDL);
- if ControlPart<>0 then
- begin
- theItem:=FindDItem(theDialog, LocalPoint);
- theItem:=SUCC(theItem);
- if theItem>0 then
- begin
- GetDItem(theDialog, theItem, ItemType, ItemHDL, ItemRect);
- if ItemType=RadioButton then
- begin
- if theItem=theListHDL^^.LastItem then
- begin
- if (theEvent.when-theListHDL^^.LastTime)<=
- GetDblTime then
- begin
- theItem:=1;
- DoDialogMouse:=TRUE;
- end; {if (theEvent.when - theListHDL^^.LastTime) <=
- GetDblTime}
- end; {if theItem = theListHDL^^.LastItem}
-
- theListHDL^^.LastItem:=theItem;
- theListHDL^^.LastTime:=theEvent.when;
- end; {if (ItemType = RadioButton)}
- end; {if theItem > 0}
- end; {if ControlPart <> 0}
- SetPort(SavePort);
- end; {DoDialogMouse}
-
- function DoDialogKeyDown(theListHDL: KeyListRecHDL;
- theDialog: DialogPtr;
- theEvent: EventRecord;
- var theItem: INTEGER): BOOLEAN;
- var
- theCharacter: str1;
- Index: INTEGER;
- begin
- theItem:=0;
- DoDialogKeyDown:=FALSE;
- theCharacter:=' ';
- theCharacter[1]:=CHR(BitAnd(theEvent.message, charCodeMask));
- if (ORD(theCharacter[1])=CR) or (ORD(theCharacter[1])=ETX) then
- begin
- theItem:=1;
- DoDialogKeyDown:=TRUE;
- end {if ORD(theCharacter[1]) = CR or ORD(theCharacter[1]) = ETX}
- else
- begin
- if CmdKeyDown(theEvent.modifiers) then
- begin
- Index:=KeyMatch(theListHDL, theCharacter);
- if Index<>0 then
- begin
- theItem:=theListHDL^^.ListHDL^^[Index].Item;
- DoDialogKeyDown:=TRUE;
- end; {if Index <> 0}
- end; {if (CharModifers > 0) and ...}
- end; {else}
- end; {DoDialogKeyDown}
-
- function CenterNewDialog;
- var
- Dialog: DialogPtr;
- DialogRect: Rect;
- begin
- Dialog:=GetNewDialog(theDialogID, dStorage, behind);
- DialogRect:=Dialog^.portRect;
- CenterInScreen(DialogRect, vOffSet, hOffSet);
- MoveWindow(Dialog, DialogRect.left, DialogRect.top, TRUE);
- CenterNewDialog:=Dialog;
- end; {CenterNewDialog}
-
- procedure OutLineButton;
- var
- OldPenState: PenState;
- SavePort: GrafPtr;
- begin
- GetPort(SavePort);
- SetPort(thePort);
- GetPenState(OldPenState);
- PenSize(3, 3);
- InsetRect(theRect, -4, -4);
- FrameRoundRect(theRect, 16, 16);
- SetPenState(OldPenState);
- SetPort(SavePort);
- end; {OutLineRect}
-
- procedure DialogDefault;
- var
- ItemHDL: Handle;
- ItemRect: Rect;
- ItemType: INTEGER;
- begin
- if theDialog<>nil then
- begin
- GetDItem(theDialog, DefaultItem, ItemType, ItemHDL, ItemRect);
- OutLineButton(theDialog, ItemRect);
- end; {if theDialog <> nil}
- end; {DialogDefault}
-
- function DialogFilter(theDialog: DialogPtr;
- var theEvent: EventRecord;
- var theItem: INTEGER): BOOLEAN;
- var
- ListRecHDL: KeyListRecHDL;
- ItemHandle: Handle;
- ControlHDL: ControlHandle;
- ItemRect: Rect;
- ItemType: INTEGER;
- RealDelay: LONGINT;
- MyItem: BOOLEAN;
- begin
- DialogFilter:=FALSE;
- MyItem:=FALSE;
- ListRecHDL:=KeyListRecHDL(GetWRefCon(theDialog));
- if ListRecHDL<>nil then
- case theEvent.what of
- mouseDown, mouseUp:
- MyItem:=DoDialogMouse(ListRecHDL, theDialog, theEvent, theItem);
-
- keyDown, autoKey:
- MyItem:=DoDialogKeyDown(ListRecHDL, theDialog, theEvent, theItem);
- end; {case theEvent.what}
-
- if MyItem then
- begin
- GetDItem(theDialog, theItem, ItemType, ItemHandle, ItemRect);
- ControlHDL:=ControlHandle(ItemHandle);
- MyItem:=(MyItem) and (ControlHDL^^.contrlHilite<>DeadControl);
- if MyItem then
- begin
- HiliteControl(ControlHandle(ItemHandle), BtnControlOn);
- Delay(EighthSecond, RealDelay);
- HiliteControl(ControlHandle(ItemHandle), BtnControlOff);
- DialogFilter:=TRUE;
- end; {if MyItem}
- end; {if MyItem}
- end; {DialogFilter}
-
- procedure SetupDialog;
- var
- ListRecHDL: KeyListRecHDL;
- ItemHDL: Handle;
- ControlHDL: ControlHandle;
- DialogRecPtr: DialogPeek;
- DialogHDR: DLOGHeaderHDL;
- ItemRect: Rect;
- ItemType, ItemCnt, Loop: INTEGER;
- begin
- if NewRoms then
- begin
- theDialogFilter:=@DialogFilter;
- ListRecHDL:=KeyListRecHDL(NewHandle(SIZEOF(KeyListRec)));
- with ListRecHDL^^ do
- begin
- ListHDL:=nil;
- ListCount:=0;
- LastItem:=0;
- OldRefCon:=GetWRefCon(theDialog);
- LastTime:=0;
- end; {with ListRectHDL^^}
-
- DialogRecPtr:=DialogPeek(theDialog);
- DialogHDR:=DLOGHeaderHDL(DialogRecPtr^.Items);
- ItemCnt:=DialogHDR^^.ItemCount;
- ItemCnt:=SUCC(ItemCnt);
-
- for Loop:=1 to ItemCnt do
- begin
- GetDItem(theDialog, Loop, ItemType, ItemHDL, ItemRect);
- ControlHDL:=ControlHandle(ItemHDL);
- case ItemType of
- ButtonItem:
- if ButtonKeys then AddKey(ListRecHDL, ControlHDL, Loop);
- CheckBox:
- if CheckBoxKeys then AddKey(ListRecHDL, ControlHDL, Loop);
- RadioButton:
- if RadioKeys then AddKey(ListRecHDL, ControlHDL, Loop);
- end; {case ItemType}
- end; {for Loop := 1 to ItemCnt}
-
- SetWRefCon(theDialog, LONGINT(ListRecHDL));
- end {if NewRoms}
- else
- theDialogFilter:=nil;
- end; {SetupDialog}
-
- procedure DisposSetUp;
- var
- ListRecHDL: KeyListRecHDL;
- RefCon: LONGINT;
- begin
- ListRecHDL:=KeyListRecHDL(GetWRefCon(theDialog));
- RefCon:=ListRecHDL^^.OldRefCon;
- if ListRecHDL^^.ListHDL<>nil then
- DisposHandle(Handle(ListRecHDL^^.ListHDL));
-
- DisposHandle(Handle(ListRecHDL));
- SetWRefCon(theDialog, RefCon);
- end; {DisposSetup}
-
- function GetDLOGRefCon;
- var
- KeyHandle: KeyListRecHDL;
- begin
- KeyHandle:=KeyListRecHDL(GetWRefCon(theDialog));
- GetDLOGRefCon:=KeyHandle^^.OldRefCon;
- end; {GetDLOGRefCon}
-
- function YesNoCancelDLOG;
- var
- Dialog: DialogPtr;
- Item: INTEGER;
- begin
- ParamText(parm0, parm1, parm2, parm3);
- Dialog:=CenterNewDialog(YesNoCancelID, nil, POINTER(-1), -50, 0);
- ShowWindow(Dialog);
- DialogDefault(Dialog);
- SetupDialog(Dialog, TRUE, TRUE, TRUE);
- ModalDialog(theDialogFilter, Item);
- DisposSetUp(Dialog);
- DisposDialog(Dialog);
- YesNoCancelDLOG:=GenericResponse(EnumValue(Item));
- end; {YesNoCancelDLOG}
-
- function YesNoDLOG;
- var
- Dialog: DialogPtr;
- ItemHDL: Handle;
- ControlHDL: ControlHandle;
- ItemRect: Rect;
- Item: INTEGER;
- begin
- ParamText(parm0, parm1, parm2, parm3);
- Dialog:=CenterNewDialog(YesNoCancelID, nil, POINTER(-1), -50, 0);
- ShowWindow(Dialog);
- GetDItem(Dialog, CancelButton, Item, ItemHDL, ItemRect);
- ControlHDL:=ControlHandle(ItemHDL);
- HideControl(ControlHDL);
- HiliteControl(ControlHDL, DeadControl);
- DialogDefault(Dialog);
- SetupDialog(Dialog, TRUE, TRUE, TRUE);
- ModalDialog(theDialogFilter, Item);
- DisposSetUp(Dialog);
- DisposDialog(Dialog);
- YesNoDLOG:=GenericResponse(EnumValue(Item));
- end; {YesNoDLOG}
-
- function DeleteFile;
- var
- Response: GenericResponse;
- FileReply: SFReply;
- TypeList: SFTypeList;
- FileErr: OSErr;
- FileCount: INTEGER;
- begin
- DeleteFile:=FALSE;
- FileCount:=-1;
-
- FileReply:=DoSFGet(FileCount, TypeList, 0, 0);
-
- if FileReply.good then
- begin
- Response:=YesNoDLOG('Do you really want to Delete the file "',
- FileReply.fName, '"?', '');
- if Response=YesResponse then
- FileErr:=FSDelete(FileReply.fName, FileReply.vRefNum);
- end; {if FileReply.good}
- end; {DeleteFile}
- end. {unitUtilities}
-